package com.daffodil.storage.config;

import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.stereotype.Component;

import com.daffodil.storage.client.SeaweedfsClient;
import com.daffodil.storage.properties.SeaweedfsProperties;
import com.daffodil.storage.properties.StorageProperties;

/**
 * 
 * @author yweijian
 * @date 2023年10月27日
 * @version 1.0
 * @description
 */
@Component
@Configuration
@ConditionalOnProperty(name = StorageProperties.NAME, havingValue = StorageProperties.SEAWEEDFS)
public class SeaweedfsClientConfig {

    @Bean
    @ConditionalOnMissingBean
    public SeaweedfsClient seaweedfsClient(StorageProperties storageProperties) {
        SeaweedfsProperties properties = storageProperties.getSeaweedfs();
        return new SeaweedfsClient(properties.getModel(), properties.getMserver(), properties.getEndpoint());
    }
}
